<?php
if (@$_POST['title']) {
	$input = $_POST;

	// 添加mongodb数据库中
	$mongo = include 'mongo.php';

	//插入数据
	//创建一个对象
	$bulk = new MongoDB\Driver\BulkWrite();
	$bulk->insert($input);
	
	// 写入数据库
	$mongo->executeBulkWrite('php71.article', $bulk);

	header('index.php');
}


?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加文章</title>
	<link rel="stylesheet" type="text/css" href="./static/css/bootstrap.min.css">
</head>
<body>
	<br>
	<div class="container">
		<form action="" method="POST" class="form-horizontal" role="form">

			<div class="form-group">
				<label class="col-sm-2 control-label">标题：</label>
				<div class="col-sm-10">
					<input type="text" name="title" class="form-control" value="">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">内容：</label>
				<div class="col-sm-10">
					<input type="text" name="cnt" class="form-control" value="">
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-10 col-sm-offset-2">
					<button type="submit" class="btn btn-primary">添加文章</button>
					<a href="index.php">返回</a>
				</div>
			</div>
		</form>
	</div>

	

	<script src="./static/js/jquery.min.js"></script>
	<script src="./static/js/bootstrap.min.js"></script>
</body>
</html>